package org.microframework.cloud.gateway.exception;

import org.springframework.http.HttpStatus;

/**
 * 网关异常
 * 用于网关内部自定义异常，包含HTTP状态码和错误消息
 */
public class GatewayException extends RuntimeException {

	private static final long serialVersionUID = 1L;
	private final HttpStatus status;
    private final int errorCode;

    public GatewayException(HttpStatus status, String message) {
        super(message);
        this.status = status;
        this.errorCode = status.value();
    }

    public GatewayException(HttpStatus status, int errorCode, String message) {
        super(message);
        this.status = status;
        this.errorCode = errorCode;
    }

    public GatewayException(HttpStatus status, String message, Throwable cause) {
        super(message, cause);
        this.status = status;
        this.errorCode = status.value();
    }

    public GatewayException(HttpStatus status, int errorCode, String message, Throwable cause) {
        super(message, cause);
        this.status = status;
        this.errorCode = errorCode;
    }

    public HttpStatus getStatus() {
        return status;
    }

    public int getErrorCode() {
        return errorCode;
    }
} 